﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace UComment.Usercontrols
{
    public partial class AjaxCommentForm : System.Web.UI.UserControl
    {
        private bool registerScripts = false;

        public bool RegisterScripts
        {
            get { return this.registerScripts; }
            set { this.registerScripts = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (registerScripts)
            {
                umbraco.library.AddJquery();
                string umbracoPath = ConfigurationManager.AppSettings["umbracoPath"];
                umbraco.library.RegisterJavaScriptFile("jquery_form", ResolveClientUrl("~/scripts/UComment/jquery.form.js"));
                umbraco.library.RegisterJavaScriptFile("jquery_metadata", ResolveClientUrl("~/scripts/UComment/jquery.metadata.js"));
                umbraco.library.RegisterJavaScriptFile("jquery_validate", ResolveClientUrl("~/scripts/UComment/jquery.validate.min.js"));
            }

            if (Page.IsPostBack)
            {
               
                Library.Base.CreateComment(umbraco.presentation.nodeFactory.Node.GetCurrent().Id);
            }
        }
    }
}